﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.Net;
using System.IO;
namespace ProcessesSMS
{
    /// <summary>
    /// Summary description for CKVN.
    /// </summary>
    public class BAOGIAODUC
    {

        private string connStringViettel = ConfigurationSettings.AppSettings["SMSConnStrViettel"].ToString();
        private SMS_MO WMO;
        private SMS_MT WMT;
        //private SMS_LIST WML;
        ArrayList arr = new ArrayList();
        public BAOGIAODUC(SMS_MO MO)
        {
            WMO = MO;
        }

        public BAOGIAODUC()
        {
        }
        public void run()
        {
            WMT = new SMS_MT(WMO);
            string tmpMsg = WMO.Message.Substring(WMO.CommandCode.Length).Trim().Replace("  ", " ").Replace("  ", " ");
            tmpMsg = tmpMsg.Replace("  ", " ").Trim().ToUpper();
            string[] msg = tmpMsg.Split(new char[] { ' ' });
            string strReturnMsg = GetReturnMsg(msg);                        
            WMT.AddMessage(WMO.UserID, strReturnMsg, SMS_ContentType.SMS_TEXT);
            WMT.MsgType = SMS_MsgType.SMS_TINHTIEN;
            WMT.Insert();            
            return;
        }
        private string GetReturnMsg(string[] msg)
        {
            string msgBody = "";
            if ((WMO.ServiceID.Replace("04", "") == "6772") || (WMO.UserID == "84902222776") || (WMO.UserID == "84978925568"))
            {

                //if (msg.Length > 0)
                //{
                    if (msg[0].ToUpper() == "01" || msg[0].ToUpper() == "1")
                    {
                        msgBody = "Bao dien tu Giao duc Viet Nam tran trong cam on quy ban doc da ung ho hoan canh co ma so 01.";
                        msgBody += "Su quan tam cua ban da mang lai hy vong cho nhieu nguoi";
                    }
                    else if (msg[0].ToUpper() == "02" || msg[0].ToUpper() == "2")
                    {
                        msgBody = "Bao dien tu Giao duc Viet Nam tran trong cam on quy ban doc da ung ho hoan canh co ma so 02.";
                        msgBody += "Su quan tam cua ban da mang lai hy vong cho nhieu nguoi";
                    }

                    else
                    {
                        msgBody = "Bao dien tu Giao duc Viet Nam tran trong cam on quy ban doc da ung ho Quy Tam Long Viet Nam.";
                        msgBody += "Su quan tam cua ban da mang lai hy vong cho nhieu nguoi";
                    }
            }
            else
            {
                msgBody = "De ung ho cho Quy Tam Long Viet Nam va cho cac hoan canh kho khan,";
                msgBody += " soan tin: UH gui 6772 hoac UH 01 gui 6772 hoac UH 02 gui 6772";
            }
            return msgBody;
        }
    }
}
